#ifndef prs_FrmRowStyle_H
#define prs_FrmRowStyle_H

#include "prs_FrmRules.h"
#include "prs_FrmFunc.h"
#include "prs_FrmStyleState.h"
#include "prs_FrmGeom.h"
#include "frm_control_TRow.h"

namespace prs {

///////////////////////////////////////////////////////////////////////////////

struct TNodeFrmRowStyle : public prs::TNodeStyleControl
{
  DECLARE_ClientNode()
  TAttrNodeType<nodeType_Row> NodeType;
  TAttrObject<nodeType_Style,frm::control::TRow::TStyle> Style;
  //
  TNodeFrmRowStyle() : NodeType(this),Style(this) {}
};

///////////////////////////////////////////////////////////////////////////////

struct TRuleFrmRowStyle : public snt::TRule
{
  TRuleFrmRowStyle(
    snt::text::TContext &Context,
    svl::TVariant &VParentNode,
    TRuleFrmStyleState &RStyleState
  );
  
private:  
  TNodeFrmRowStyle *GetNode() { return dynamic_cast<TNodeFrmRowStyle*>(vParentNode.Pointer());}
  //
  void FNormal  (snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.Normal );}
  void FIndent  (snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.Indent );}
  void FChildren(snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.Children );}
  //
  void FCaptionNormal  (snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.Caption.Normal );}
  void FCaptionSelected(snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.Caption.Selected );}
  void FCaptionFocused (snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.Caption.Focused );}
  //
  bool FIndentWidth(snt::text::TNumber::TFuncClosureDoEntryParams &Params);
  //
  svl::TVariant &vParentNode;
  TRuleFrmStyleState &rStyleState;
  snt::TRule  RIndent;
  snt::TAlter A,AIndent;
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

struct TNodeFrmRowExpandStyle : public prs::TNodeStyleControl
{
  DECLARE_ClientNode()
  TAttrNodeType<nodeType_RowExpand> NodeType;
  TAttrObject<nodeType_Style,frm::control::TRowExpand::TStyle> Style;
  TAttrNodeObject<attrName_Geometry,TNodeFrmGeom> Geometry;
  //
  TNodeFrmRowExpandStyle() : NodeType(this),Style(this),Geometry(this) {}
};

///////////////////////////////////////////////////////////////////////////////

struct TRuleFrmRowExpandStyle : public snt::TRule
{
  TRuleFrmRowExpandStyle(
    snt::text::TContext &Context,
    svl::TVariant &VParentNode,
    TRuleFrmStyleState &RStyleState,
    TRuleFrmGeom &RFrmGeom
  );
  
private:  
  TNodeFrmRowExpandStyle *GetNode() { return dynamic_cast<TNodeFrmRowExpandStyle*>(vParentNode.Pointer());}
  void FSetGeometry(snt::TParams &Params) { rGeometry.SetGeom( &GetNode()->Geometry.Value );}
  //
  void FNoneChildren(snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.NoneChildren );}
  void FCollapse    (snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.Collapse );}
  void FExpand      (snt::TParams &Params) { rStyleState.SetState( &GetNode()->Style.Value.Expand );}
  //
  svl::TVariant &vParentNode;
  TRuleFrmStyleState &rStyleState;
  TRuleFrmGeom &rGeometry;
  snt::TAlter A;
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////
}

#endif
